package demo.thread;

public class TT implements Runnable {
    int b = 100;

    public synchronized void m1() throws Exception {
        b = 1000;
        System.out.println("sleep2000");
        Thread.sleep(2000);
        System.out.println("m1():b=" + b);
    }

    public void m2() throws Exception {
//		Thread.sleep(1000);
        b = 2000;
        System.out.println("m2():b=" + b);
    }

    public void run() {
        try {
            m1();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) throws Exception {
        TT tt = new TT();
        Thread t = new Thread(tt);
        t.start();
//        Thread.sleep(500);
        System.out.println("sleep500");
        tt.m2();

    }
}
